<!--
 @description 经销商收货地址
 @fileName Address.vue
 @author zengqiongying
 @created 2023/04/28 13:54:59
-->
<template>
  <div>
    <Card v-for="(item, i) in list" :key="`${i}-${item.code}`">
      <template #title>
        <div class="card-header">
          <span class="name"><span class="icon"></span>收货地址{{ i + 1 }}</span>
        </div>
      </template>
      <Cell
        v-if="['A', 'B', 'C'].includes(item.changeType)"
        title="变更类型"
        :modelValue="item.changeType === 'B' ? '新增' : item.changeType === 'A' ? '变更' : '停用'"
        readonly
      />
      <AddressItem :modelValue="item" />
    </Card>
    <qmp-empty v-if="list.length === 0" description="暂无收货地址" image-size="60px" />
  </div>
</template>

<script lang="ts">
  import { reactive, toRefs } from 'vue'
  import { useRoute } from 'vue-router'
  import Card from '@/components/Card/index.vue'
  import Cell from '@/components/Cell/index.vue'
  import AddressItem from '../../components/Address/ItemView.vue'
  import { addressMixin } from '../../mixins/Address'

  export default {
    name: 'DealerNewShopDetailAddress',
    components: { Card, Cell, AddressItem },
    setup() {
      const $route = useRoute()
      const { datas, getList } = addressMixin()
      datas.id = $route.query?.id || ''
      getList()

      return {
        ...toRefs(datas)
      }
    }
  }
</script>
<style lang="less" scoped>
  @import url('../../styles/common.less');
</style>
